<?php
header('Content-Type: text/html; charset=UTF-8');
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type='text/javascript' src='query/jquery-1.11.1.min.js'></script>
<script type='text/javascript'>
  	$.ajaxSetup({
		dataType:'JSON',
		error:function(){
			alert('链接错误');
		},
	});
	$(function(){
		$('#a').click(function(){
			$('#img').attr('src','img.php')
		});
		
		$('#loginButton').click(function(){
			
			/*
			if(($('#loginInput').val().trim()==''||($('#passwordInput').val().trim()==''))){
				alert('密码和登录名都不能为空');
				return;
			}
			*/ 
			$.post('login.php',$('form').serialize(),function(o){
				if(!o.status){
					alert(o.info);
				}else{
					$('#login').css('display','none');
					$('#main').css('display','block');
				}
			});
		});
		$('#logoutbut').click(function(){
			$.post('logout.php',function(o){
			var flag = confirm('确定退出吗？');
			  if(flag){
				$('#loginInput').val('');
				$('#passwordInput').val('');
				$('#login').css('display','block');
				$('#main').css('display','none');
				
				}
				
			});
		});

		$('#lookbut').click(function(){
			$.post('look.php',function(o){
			if(o.status){
				alert(o.info);
				}else{
					$('#sur').html('你的当前余额为：'+o.money+'元');
					}
			});
		});

		$('#addbut').click(function(){
			var inCash = prompt('请输入存款金额：');
			if(inCash==null){
				return;
				}
			if(inCash.trim()==''||isNaN(inCash)||parseInt(inCash%100)){
				alert('存入金额只能是100的整数倍');
				return;
				}
			$.post('add.php',{'inCash':inCash},function(o){
			if(!o.status){
				alert(o.info);
				}else{
					$('#sur').html('存款成功!你的当前余额为：'+o.money+'元');
					}
			});
		});


		$('#getbut').click(function(){
			var outCash = prompt('请输入取款金额：');
			if(outCash==null){
				return;
				}
			if(outCash.trim()==''||isNaN(outCash)||parseInt(outCash%100)){
				alert('取款金额只能是100的整数倍');
				return;
				}
			$.post('get.php',{'outCash':outCash},function(o){
				if(!o.status){
					alert(o.info);
				}else{
					$('#sur').html('取款成功!你的当前余额为：'+o.money+'元');
				}
			});
		});

			
	});
	
 </script>
 <style type='text/css'>
 	<?php  if(empty($_SESSION['userId'])){ ?>
	 #main{display:none;}
	<?php  }else{ ?>
	 #login{display:none;}
	<?php } ?>
 #p{margin:30px auto}
 #login{border:1px solid;width:370px;height:380px;margin:100px auto;text-align:center;color:black;padding:25px;background:url(d.png);}
 #loginInput{font-size:20px}
 #passwordInput{font-size:20px}
 #loginButton{margin:50px auto;width:70px;height:30px;font-size:20px;float:right;margin:90px auto;background:#758e31;color:red}
 #main{border:solid 1px;width:380px;height:390px;margin:100px auto;text-align:center;padding:20px;color:black;background:url(d.png)}
 #div{width:400px;height:220px;margin:40px auto;}
 #sur{border:solid 1px;width:160px;height:180px;background:;padding:12px;float:left;font-size:20px;}
 #div1{float:left;width:60px;height:190px;padding:18px}
 #div2{float:left;width:60px;height:190px;padding:18px}
 #lookbut{margin:10px;width:55px;height:30px;background:#758e31;margin:17px auto }
 #getbut{margin:10px;width:55px;height:30px;background:#758e31;margin:17px auto}
 #yw{margin:10px;width:55px;height:30px;background:#758e31;margin:17px auto}
 #addbut{margin:10px;width:55px;height:30px;background:#758e31;margin:17px auto}
 #zr{margin:10px;width:55px;height:30px;background:#758e31;margin:17px auto}
 #logoutbut{margin:10px;width:55px;height:30px;background:#758e31;margin:17px auto}
 #code *{vertical-align:middle;width:82px;height:23px}
 </style>
</head>
 <body>
<div id="login">
 	<img src="yz.png"/>
 	<form>
		用户名：<input name="login" id="loginInput"/><br/>
	   <div id="p"> 密　码：<input name="password" id="passwordInput" type="password"/><br/></div>
 	</form>
	  	<div id="code"> 验证码：<input name="code" id="code"/>
	   		<img id="img" src="img.php"/>
			<a href="" id="a">换一张</a>
	  </div>
	<button id="loginButton">登录</button>
</div>

<div id="main">
<br/>
<img src="yz.png"/>
  <div id="div">
  		<div id="div1">
			<button id="lookbut">余 额</button>
			<button id="getbut">取 款</button>
			<button id="yw">业 务</button>
  		</div>
		<div id="sur"></div>
		<div id="div2">
			<button id="addbut">存 款</button>
			<button id="zr">转 帐</button>
			<button id="logoutbut">登 出</button>
		</div>
  </div>
</div>
</body>
</html>

